-
Notifications
You must be signed in to change notification settings - Fork 1.4k
No automatic completion support unless needed - Revisited #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cliffhall
wants to merge
6
commits into
modelcontextprotocol:main
Choose a base branch
from
cliffhall:no-auto-completions-support-unless-needed-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
No automatic completion support unless needed - Revisited #1024
cliffhall
wants to merge
6
commits into
modelcontextprotocol:main
from
cliffhall:no-auto-completions-support-unless-needed-2
+105
−7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- add `isCompletable` function, a runtime type guard to detect `Completable`-wrapped Zod types
* In mcp.test.ts
- Added tests
- "should not advertise support for completion when a resource template without a complete callback is defined"
- "should not advertise support for completion when a prompt without a completable argument is defined"
* In mcp.ts
- in `handlePromptCompletion` method,
- fix warning "Invalid 'instanceof' check: 'field' has type that is not related to 'Completable<any>'" by using the new `isCompletable` function from `completable.ts`
- in `setResourceRequestHandlers` method
- remove unconditional call to `setCompletionRequestHandler` - supporting resources does not automatically mean that resource template completion is supported
- in `setPromptRequestHandlers` method
- remove unconditional call to `setCompletionRequestHandler` - supporting prompts does not automatically mean that prompt argument completion is supported
- in `_createRegisteredResourceTemplate` method
- check if the resource template being registered has a complete callback,
- if so, call `setCompletionRequestHandler`
- in _`createRegisteredPrompt` method
- check if any argument of the prompt has a `Completable` schema
- if so, call `setCompletionRequestHandler`
9 tasks
Member
evalstate
approved these changes
Oct 20, 2025
commit: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


Description
isCompletablefunction, a runtime type guard to detectCompletable-wrapped Zod typeshandlePromptCompletionmethod,isCompletablefunction fromcompletable.tssetResourceRequestHandlersmethodsetCompletionRequestHandler- supporting resources does not automatically mean that resource template completion is supportedsetPromptRequestHandlersmethodsetCompletionRequestHandler- supporting prompts does not automatically mean that prompt argument completion is supported_createRegisteredResourceTemplatemethodsetCompletionRequestHandlercreateRegisteredPromptmethodCompletableschemasetCompletionRequestHandlerMotivation and Context
@evalstate discovered that when registering a prompt or resource template, it was automatically setting a completion request handler and advertising the
completionscapability. However in order to support completions, at least one argument of a prompt must have aCompletableschema or one argument of a resource template must have acompleteCallback.In his case, he was not supporting
completionson his prompts and resources, and was concerned that clients would send unnecessary completion requests because of this automatic advertisement of completions.This PR checks each registered prompt and resource template, and only does automatic advertisement and listening for completion requests if completable argument is found.
How Has This Been Tested?
Breaking Changes
Nope. Existing behavior for auto-advertisement of completions will still allow completable arguments to be completed. If no completable prompt or resource template arguments exist, then the previous behavior of allowing completion requests was a bug and will now be defeated.
Types of changes
Checklist
Additional context
Redo of #974. It had been approved but never merged, and when I tried to resolve conflicts, the
mcp.tsfile had changed too much to do it with confidence. So, I made the changes again against what's currently onmain.